<?php
  require_once('./db.php');
  //pr($_SESSION['uid']);
  //pr($_POST['uid']);
if(isset($_POST['email']) &&
 !empty($_POST['email']) &&
 ($_SESSION['uid'] == $_POST['uid'])
 )
{
  $_SESSION['uid']='';
  unset($_POST['uid']);
  $_POST['added_date'] = date('Y-m-d H:i:s');
  $_POST['status'] = '1';
  pr($_POST);
  $query = "INSERT INTO `users` SET ";
  $tmp = '';
  foreach ($_POST as $colName => $value) {
    $tmp .= "`$colName`='$value' ,";
  }
  $query = $query.$tmp;
  $query = rtrim($query," ,");
  print_q($query);
  mysql_query($query)or die(mysql_error());
  $id = mysql_insert_id();
  echo "Record inserted on Id :$id";
  header("location:success.php");
  exit;
}
?>
<form action="" method="post">
  <input type="text" name="uid" value="<?=$uid?>"/>
  <table  border="1" cellpadding="0" cellspacing="0" width="80%" align="center">
    <thead>
      <tr>
        <th colspan="2">::Please add user::</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td align="right">User Name :</td>
        <td ><input required type="text" name="uname" placeholder="My Name is.."/></td>
      </tr>
      <tr>
        <td align="right">Email :</td>
        <td ><input required type="email" name="email" placeholder="My Email is.."/></td>
      </tr>
      <tr>
        <td align="right">Password :</td>
        <td ><input required type="password" name="password" placeholder="My Password is.."/></td>
      </tr>
      <tr>
        <td align="right">&nbsp;</td>
        <td ><input type="submit" value="I am done!!" /></td>
      </tr>
    </tbody>
  </table>
</form>
